package com.dhsc.service.impl.khzne;

import com.dhsc.domain.ywzx.khzne.XzxjzckhVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.ywzj.khzne.IYwXzxjzckhDao;
import com.dhsc.service.khzne.IYwXzxjzckhService;
import com.dhsc.util.CommonUtil;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 闲置现金资产客户
 * @date 2024/11/6 11:30
 */
@Slf4j
@Service
public class YwXzxjzckhServiceImpl implements IYwXzxjzckhService {

    @Autowired
    private IYwXzxjzckhDao xzxjzckhDao;

    @Override
    public LayuiTableVo queryXzxjzckhinfo(XzxjzckhVo x) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            if(!CommonUtil.isNotEmptyObj(x.getState())){
                PageMethod.startPage(x.getPage(), x.getLimit());
            }
            List<XzxjzckhVo> list = xzxjzckhDao.queryXzxjzckhinfo(x);
            PageInfo<XzxjzckhVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch (Exception e){
            log.error("查询闲置现金资产客户出错",e);
            throw new MyException("查询闲置现金资产客户出错",e);
        }
        return obj;
    }
}
